package com.zzz.offer.twoSum;

import java.util.*;

public class Solution {
    public static void main(String[] args) {
    }

    public static int[] twoSum(int[] nums, int target) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            int other = target - nums[i];
            if (map.get(other) != null && map.get(other) != i) {
                return new int[]{map.get(other), i};
            }
            map.put(nums[i], i);
        }
        return new int[]{0, 0};
    }
}
